EJB Dwarf Manager

Java Dwarf Manager is here re-implemented using the JBoss Open Source J2EE EJB (Enterprise Java Beans) Application Server. Dwarf Manager continues to use Struts, Tomcat, and Postgresql.

Overview

JBoss 3.0 supports CMP (Container Managed Persistence) 2.0. For EJB Dwarf Manager the basic back-end architecture consists of a Stateless Session Bean Facade of DwarfMgr and MountainMgr, providing the same APIs as their previous incarnation as jdbc database access classes. They still return lists of (regular) Java Beans. The Mgrs are implemented internally using DwarfEntity and MountainEntity, CMP Entity Beans with only local interfaces. They also implement Entity Relationships between themselves.

Struts View

The View jsp web pages are basically unchanged, except where they previously referenced Mgr classes (should be entirely factored out to controllers...)

Note the following are static screen shots. This site is not dynamically hosted.

Generated HTMLJSP Source (View->Source)
Main Main.jsp
AddDwarf AddDwarf.jsp
AddMountain AddMountain.jsp
UpdateDwarf UpdateDwarf.jsp
UpdateMountain UpdateMountain.jsp

Struts Model

The Model Java Beans are unchanged from Java Dwarf Manager.

Form Beans
MainForm.java
DwarfForm.java
MountainForm.java

Struts Controller

The Controller classes have been modified to use the new Stateless Session Bean Facade Mgr classes, accessed via MgrFactory.java:

Action Classes
EnterMainAction.java
AddDwarfAction.java
EditDwarfAction.java
SaveDwarfAction.java
AddMountainAction.java
EditMountainAction.java
SaveMountainAction.java

The struts-config.xml file is unchanged.

Database

The Postgres SQL schema scripts have been modified to no longer use declared serial columns in the schema to automatially generate primary keys. Instead the Entity Beans use Sequence.java to manually call nextval() on Postgres sequences via JDBC.

SQL Files
Dwarf_Schema.sql
Dwarf_Load.sql
Drop_Database.sql

Bean Data Objects

Java Bean data objects are still used to pass returned results from Mgr queries:

Data Objects
Dwarf.java
Mountain.java

EJBs

Stateless Session Bean Facade
DwarfMgr.java
DwarfMgrHome.java
DwarfMgrBean.java
MountainMgr.java
MountainMgrHome.java
MountainMgrBean.java

CMP 2.0 Local Entity Beans
DwarfEntity.java
DwarfEntityHome.java
DwarfEntityBean.java
MountainEntity.java
MountainEntityHome.java
MountainEntityBean.java

XML Deployment Descriptors
ejb-jar.xml (View->Source)
jboss.xml
jbosscmp.xml

Here's a tar of all the source: dwarf.tar

Analysis

Here are Postgresql traces of some common operations being performed on both Java Dwarf Manager (2-tier JDBC) and JBoss EJB Dwarf Manager. JBoss generates a lot more database access. It never uses joins, loads many more rows than necessary, and updates all rows to lock them even when the access in a useage is read-only. Much of this behavior can (supposedly) be modified via deployment descriptor options...

JDBCJBoss EJB
Enter Main Enter Main
Enter Edit Mountain Enter Edit Mountain

A Ruby Code Generator can be used to generate the Entity Beans and associated XML deployment descriptors from the SQL schema.

Code developed on Mac OS X using Java 1.3.1, JBoss 3.0.0beta.